package com.android.miniProject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ServicesMusic extends Activity {
  private static final String TAG = "ServicesDemo";
//  Button buttonStart, buttonStop , buttonMenu;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.music);

//  buttonStart = (Button) findViewById(R.id.buttonStart);
//  buttonStop = (Button) findViewById(R.id.buttonStop);
//
//  buttonMenu = (Button) findViewById(R.id.buttonMenu);

//  
//  
//  buttonStart.setOnClickListener(this);
//  buttonStop.setOnClickListener(this);
//  buttonMenu.setOnClickListener(this);
    // Click Listener
    OnClickListener clickListener = new OnClickListener()
    {
      @Override
      public void onClick(View actualView)
      {
    	  switch(actualView.getId()){
    	    
	  	// Boutons du menu
	  	case R.id.button1 :       	  
	  		// Navigation to runActivity
	  		Intent runIntent = new Intent(actualView.getContext(), RunActivity.class);
	  		startActivity(runIntent);
	  		break;
	  	case R.id.button2 : 
	  		// Navigation to TrainingActivity
	  		Intent trainingIntent = new Intent(actualView.getContext(), TrainingActivity.class);
	  		startActivity(trainingIntent);
	  		break;
	  	case R.id.button3:
	  		Intent analyseIntent = new Intent(actualView.getContext(),AnalyseActivity.class);
	  		startActivity(analyseIntent);
	  		break;
	  		
	  	case R.id.button4 : 
	  		findViewById(R.id.button2).setEnabled(false);
	  		break;
    	  	
    	  }
      }
   };
   
   Button newRun = (Button) findViewById(R.id.button1);
   newRun.setOnClickListener(clickListener);
   
   Button trainings = (Button) findViewById(R.id.button2);
   trainings.setOnClickListener(clickListener);
   
   Button post_run = (Button) findViewById(R.id.button3);
   post_run.setOnClickListener(clickListener);
   
   Button settings = (Button) findViewById(R.id.button4);
   settings.setOnClickListener(clickListener);
    
  
}



  
  public void onClick(View src) {
    switch (src.getId()) {
    case R.id.buttonStart:
      Log.d(TAG, "onClick: starting srvice");
      startService(new Intent(this, MyService.class));
      break;
    case R.id.buttonStop:
      Log.d(TAG, "onClick: stopping srvice");
      stopService(new Intent(this, MyService.class));
      break;
      		
   	// Boutons du menu
  	case R.id.button1 :       	  
  		// Navigation to runActivity
  		Intent runIntent = new Intent(ServicesMusic.this, RunActivity.class);
  		startActivity(runIntent);
  		break;
  	case R.id.button2 : 
  		// Navigation to TrainingActivity
  		Intent trainingIntent = new Intent(ServicesMusic.this, TrainingActivity.class);
  		startActivity(trainingIntent);
  		break;
  	case R.id.button3:
  		Intent analyseIntent = new Intent(ServicesMusic.this,AnalyseActivity.class);
  		startActivity(analyseIntent);
  		break;
  		
  	case R.id.button4 : 
  	// Navigation to ServicesDemo (MUSIC in background : see services)
  		Intent musicIntent = new Intent(ServicesMusic.this,ServicesMusic.class);
  		startActivity(musicIntent);
  		break;
	  	
    }
  }
}

